<%= form_tag({controller: "users", action: "update"}, method: :put, multipart: true) do %>
    <!--<div class="form-group">
        <%= label_tag :email, "邮箱" %>
        <%= text_field :user, :email, class: "form-control disabled", value: current_user.email %>
    </div>-->
    <div class="form-group">
        <%= label_tag :name, "名字" %>
        <%= text_field :user, :name, value: current_user.name, class: "form-control" %>
    </div>
    <div class="form-group">
        <%= label_tag :old_password,  "原密码" %>
        <%= password_field_tag "user[old_password]", nil, class: "form-control"  %>
    </div>
    <div class="form-group">
        <%= label_tag :new_password,  "新密码" %>
        <%= password_field_tag "user[new_password]", nil, class: "form-control" %>
    </div>
    <div class="form-group">
        <%= label_tag :img, "头像" %>
        <%= file_field :user, :avatar %>
        <%= image_tag(@att.avatar.little.url) if @att %>
    </div>
    <%= submit_tag "提交", class: "btn btn-primary", data: { disable_with: "Please wait..." }  %>
<% end %>
<script type="text/javascript">
    //alert($("#user_old_password").val() == "")
    //alert($("#user_name").val())
    /*jQuery.validator.setDefaults({
        debug: true,
        success: "valid"
    });*/

    $("form").validate({
        rules: {
            "user[name]": {
                required: true,
                minlength:4
            },
            "user[old_password]": {
                required: function(){return $("#user_old_password").val() != ""},
                minlength: 6
            },
            "user[new_password]": {
                required: function(){return $("#user_new_password").val() != ""},
                minlength: 6
            }
        }
    })
</script>
